package com.youhp.spire.xls.demo.Charts.ManipulateChart;

import com.spire.xls.*;
import com.spire.xls.charts.*;

public class DataCallout {

    public static void main(String[] args) {
        //Create a Workbook
        Workbook workbook = new Workbook();
        workbook.loadFromFile("data/DataCallout.xlsx");

        //Get the first sheet
        Worksheet sheet = workbook.getWorksheets().get(0);

        //Get the first chart
        Chart chart = sheet.getCharts().get(0);

        ChartSeries series = chart.getSeries();
        for (int i = 0; i < series.size(); i++) {
            ChartSerie cs = series.get(i);
            cs.getDataPoints().getDefaultDataPoint().getDataLabels().hasValue(true);
            cs.getDataPoints().getDefaultDataPoint().getDataLabels().hasWedgeCallout(true);
            cs.getDataPoints().getDefaultDataPoint().getDataLabels().hasCategoryName(true);
            cs.getDataPoints().getDefaultDataPoint().getDataLabels().hasSeriesName(true);
            cs.getDataPoints().getDefaultDataPoint().getDataLabels().hasLegendKey(true);
        }

        //Save the result file
        workbook.saveToFile("output/DataCallout.xlsx", FileFormat.Version2010);
    }
}
